Wordpress - Snippets: Unterschied zwischen den Versionen
Aus Wikizone
| (2 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
| + | == Absender E-Mail anpassen == | ||
| + | https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_from_name | ||
| + | https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_from | ||
| + | |||
| + | Die Mail-Adresse kann man in den Einstellungen zwar anpassen, aber bei manchen Tools wird trotzdem wordpress@... und als Absender Wordpress gesendet. Das ist manchmal unpraktisch. Z.B. wenn man mehrere Instanzen zu verwalten hat. So kann man es ändern. | ||
| + | |||
| + | '''Den Absendernamen für die automatischen E-Mails anpassen''' | ||
| + | |||
| + | <syntaxhighlight lang="php"> | ||
| + | add_filter( 'wp_mail_from_name', 'custom_wp_mail_from_name' ); | ||
| + | function custom_wp_mail_from_name( $original_email_from ) { | ||
| + | return 'WordPress Email System'; | ||
| + | } | ||
| + | |||
| + | //It is not necessary to call another method if you can use anonymous functions (PHP 5.3.0+): | ||
| + | |||
| + | add_filter( 'wp_mail_from_name', function( $name ) { | ||
| + | return 'WordPress Email System'; | ||
| + | }); | ||
| + | |||
| + | </syntaxhighlight> | ||
| + | |||
| + | '''Sende E-Mail Adresse anpassen:''' | ||
| + | |||
| + | <syntaxhighlight lang="php"> | ||
| + | |||
| + | add_filter( 'wp_mail_from', 'custom_wp_mail_from' ); | ||
| + | function custom_wp_mail_from( $original_email_address ) { | ||
| + | //Make sure the email is from the same domain | ||
| + | //as your website to avoid being marked as spam. | ||
| + | return 'webmaster@mydomainname.com'; | ||
| + | } | ||
| + | |||
| + | //It is not necessary to call another method if you can use anonymous functions (PHP 5.3.0+): | ||
| + | |||
| + | add_filter( 'wp_mail_from', function( $email ) { | ||
| + | return 'webmaster@mydomainname.com'; | ||
| + | }); | ||
| + | |||
| + | </syntaxhighlight> | ||
== Nach Login auf Homepage weiterleiten == | == Nach Login auf Homepage weiterleiten == | ||
Es gibt ein paar Plugins dazu. Prinzipiell kann man einfach eine action ins Theme nehmen. | Es gibt ein paar Plugins dazu. Prinzipiell kann man einfach eine action ins Theme nehmen. | ||
| Zeile 17: | Zeile 57: | ||
== Taxonomien im Backend nutzen == | == Taxonomien im Backend nutzen == | ||
[[Wordpress Plugina - Taxonomien nutzen]] | [[Wordpress Plugina - Taxonomien nutzen]] | ||
| + | |||
| + | == Admin User über FTP erzeugen == | ||
| + | Dieses Snippet anpassen, in die functions.php des Themes kopieren und Seite aufrufen. Nicht vergessen wieder entfernen. | ||
| + | |||
| + | <syntaxhighlight lang="php"> | ||
| + | function add_admin_acct(){ | ||
| + | $login = 'benutzername'; | ||
| + | $passw = 'meinpasswort'; | ||
| + | $email = 'schlegel@geo-bit.de'; | ||
| + | |||
| + | if ( !username_exists( $login ) && !email_exists( $email ) ) { | ||
| + | $user_id = wp_create_user( $login, $passw, $email ); | ||
| + | $user = new WP_User( $user_id ); | ||
| + | $user->set_role( 'administrator' ); | ||
| + | } | ||
| + | } | ||
| + | add_action('init','add_admin_acct'); | ||
| + | |||
| + | </syntaxhighlight> | ||
Aktuelle Version vom 16. Mai 2019, 13:50 Uhr
Absender E-Mail anpassen[Bearbeiten]
https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_from_name https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_from
Die Mail-Adresse kann man in den Einstellungen zwar anpassen, aber bei manchen Tools wird trotzdem wordpress@... und als Absender Wordpress gesendet. Das ist manchmal unpraktisch. Z.B. wenn man mehrere Instanzen zu verwalten hat. So kann man es ändern.
Den Absendernamen für die automatischen E-Mails anpassen
add_filter( 'wp_mail_from_name', 'custom_wp_mail_from_name' );
function custom_wp_mail_from_name( $original_email_from ) {
return 'WordPress Email System';
}
//It is not necessary to call another method if you can use anonymous functions (PHP 5.3.0+):
add_filter( 'wp_mail_from_name', function( $name ) {
return 'WordPress Email System';
});
Sende E-Mail Adresse anpassen:
add_filter( 'wp_mail_from', 'custom_wp_mail_from' );
function custom_wp_mail_from( $original_email_address ) {
//Make sure the email is from the same domain
//as your website to avoid being marked as spam.
return 'webmaster@mydomainname.com';
}
//It is not necessary to call another method if you can use anonymous functions (PHP 5.3.0+):
add_filter( 'wp_mail_from', function( $email ) {
return 'webmaster@mydomainname.com';
});
Nach Login auf Homepage weiterleiten[Bearbeiten]
Es gibt ein paar Plugins dazu. Prinzipiell kann man einfach eine action ins Theme nehmen.
In die function.php des Themes einfügen (z.b. einfach ganz oben nach dem <?php ):
/* redirect users to front page after login */
function redirect_to_front_page() {
global $redirect_to;
if (!isset($_GET['redirect_to'])) {
$redirect_to = get_option('siteurl');
}
}
add_action('login_form', 'redirect_to_front_page');
Taxonomien im Backend nutzen[Bearbeiten]
Wordpress Plugina - Taxonomien nutzen
Admin User über FTP erzeugen[Bearbeiten]
Dieses Snippet anpassen, in die functions.php des Themes kopieren und Seite aufrufen. Nicht vergessen wieder entfernen.
function add_admin_acct(){
$login = 'benutzername';
$passw = 'meinpasswort';
$email = 'schlegel@geo-bit.de';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
add_action('init','add_admin_acct');