dnd 5e – Is a creature’s Innate Spellcasting save DC affected by changing ability scores or adding Spellcasting features from another creature?

Yes

Spellcasting save DCs for monsters are calculated by:

$$8 + text{Proficiency Bonus} + text{spellcasting ability modifier}$$

If you are using the higher Intelligence score, it would also increase the spellcasting save DC.

As a side note, the Proficiency Bonus of a monster is determined by the Challenge Rating, as detailed in Chapter 12 of the Basic Rules.

dnd 5e – Does adding multiple skills when combining creatures cause balance issues?

Is it balanced?

In my experience, skills like Investigation, Arcana, and History are rarely used by monsters. If you are in a game where they are used more often, this might have a bigger impact, but I doubt that having the skill proficiencies will affect balance significantly.

As for the saving throws, the Evil Mage already has these two proficiencies without much of an issue. That being said, if this homebrew character also has the chain mail that the typical svirfneblin monster stat block has, these proficiencies will strengthen its defenses against certain spells that the svirfneblin usually struggles with. I don’t this is unbalancing, but it is worth considering.

CR and balance

To start with, CR is not always the best metric of balance; whether a changes to a creature is balanced entirely depends on what you are balancing against, and the other traits the monster has.

That being said, the Dungeon Master’s Guide does provide guidance on how to calculate CR for monsters. This, while not a perfect metric for balance, is the best official guidance we have.

Saving Throw proficiencies are factored in to CR, skill proficiencies are not.

Saving Throws

From the “Creating a Monster” section of Chapter 9 of the Dungeon Master’s Guide:

If you want a monster to be unusually resistant to certain kinds of effects, you can give it a bonus to saving throws tied to a particular ability.

(…)

A monster with three or more saving throw bonuses has a significant defensive advantage, so its effective AC (not its actual AC) should be raised when determining its challenge rating.

Effective AC is used to calculate the Defensive Challenge Rating portion of a monsters Challenge Rating (which is averaged with the Offensive Challenge Rating), so having three or more saving throw proficiencies affects CR.

In your specific case of only two, it does not affect CR.

Skill Proficiencies

From the same section of the Dungeon Master’s Guide:

If you want a monster to be proficient in a skill, you can give it a bonus equal to its proficiency bonus on ability checks related to that skill.

(…)

Skill bonuses have no bearing on a monster’s challenge rating.

wordpress – Adding custom variables to woocommerce email templates

I’m trying to add a custom variable to the woocommerce email templates.

I need to add a UTM tag to all of the links and would like to pass a custom variable depending on the email_id.

The links I’m adding are in the email-header.php & email-footer.php file and I want to append a string to the links.

How do I create a variable that can be passed to both templates? Is there a global object or array I can add this to?

I’m using Woocommerce 4.2.2.

python – django-allauth multiple user type: adding users through admin portal

I’m new to Django and django-allauth, and would appreciate your help!

I’m building out a custom User (email authentication with no username) with multiple user proxy models and associated user profiles (Student, Teacher, etc.), each with their own unique fields and unique sign-in form.

Current Challenges:

  1. Normal login and signup work. Unfortunately, new user creation with a superuser account on the admin portal fails with no trace; only displays “Please correct the error below.”

  2. This might be an easier fix… When I create a new superuser, its base_type is set to STUDENT. Is there a quick way to save superusers with type ADMIN rather than STUDENT?

Disclaimer: The jumble of code below was put together from a variety of tutorials. If there’s ways to improve beyond solving 1 and 2, would be happy to hear your input.

Cheers!

# models.py

class CustomUserManager(BaseUserManager):
    """User manager with no username field."""

    use_in_migrations = True

    def _create_user(self, email, password, **extra_fields):
        if not email:
            raise ValueError(_('The Email must be set'))
        email = self.normalize_email(email)
        user = self.model(email=email, **extra_fields)
        user.set_password(password)
        user.save()
        return user

    def create_user(self, email, password=None, **extra_fields):
        extra_fields.setdefault('is_staff', False)
        extra_fields.setdefault('is_superuser', False)
        extra_fields.setdefault('is_active', True)
        return self._create_user(email, password, **extra_fields)

    def create_superuser(self, email, password, **extra_fields):
        extra_fields.setdefault('is_staff', True)
        extra_fields.setdefault('is_superuser', True)
        extra_fields.setdefault('is_active', True)

        if extra_fields.get('is_staff') is not True:
            raise ValueError('Superuser must have is_staff=True.')
        if extra_fields.get('is_superuser') is not True:
            raise ValueError('Superuser must have is_superuser=True.')

        return self._create_user(email, password, **extra_fields)

class User(AbstractUser):

    class Types(models.TextChoices):
        STUDENT = "STUDENT", 'student'
        TEACHER = "TEACHER", 'teacher'
        ADMIN = "ADMIN", 'admin'
    
    username = None
    email = models.EmailField(_('email address'), unique=True)
    base_type = Types.STUDENT
    user_type = models.CharField(
        _("User Type"), max_length=50, choices=Types.choices, default=base_type
    )

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ()

    objects = CustomUserManager()

    def save(self, *args, **kwargs):
        if not self.id:
            self.user_type = self.base_type
        return super().save(*args, **kwargs)

    def __str__(self):
        return self.email


class Grade(models.TextChoices):
    GRADE1 = "GRADE1”, "Grade 1”
    GRADE2 = "GRADE2”, "Grade 2”
    GRADE3 = "GRADE3”, "Grade 3”
    # …. 

class StudentManager(CustomUserManager):
    def get_queryset(self, *args, **kwargs):
        return super().get_queryset(*args, **kwargs).filter(user_type=User.Types.STUDENT)

class StudentProfile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    grade_level = models.CharField(
        _("Grade"), max_length=50, choices=Grade.choices, null=False, blank=False
    )

class Student(User):
    base_type = User.Types.STUDENT
    objects = StudentManager()

    @property
    def profile(self):
        return self.studentprofile

    class Meta:
        proxy = True
# forms.py

class StudentSignUpForm(UserCreationForm):
    grade_level = forms.ChoiceField(
        choices=Grade.choices,
        label="Grade Level",
        initial='',
        widget=forms.Select(),
        required=True
    )

    class Meta(UserCreationForm.Meta):
        model = Student
        fields = ('email', 'first_name', 'last_name')

    @transaction.atomic
    def save(self):
        user = super().save(commit=False)
        user.user_type = User.Types.STUDENT
        user.save()
        student = StudentProfile.objects.create(user=user, grade_level=self.cleaned_data.get('grade_level'))
        return user

# views.py

class StudentSignUpView(CreateView):
    model = Student
    form_class = StudentSignUpForm
    template_name = 'account/signup_form.html'

    def get_context_data(self, **kwargs):
        kwargs('user_type') = 'student'
        return super().get_context_data(**kwargs)

    def form_valid(self, form):
        user = form.save()
        login(self.request, user)
        return redirect('students:assignments_list')

# ...
# admin.py

class CustomUserAdmin(UserAdmin):
    
    list_display = ('first_name', 'last_name', 'email', 'is_staff', 'is_active',)
    list_filter = ('email', 'is_staff', 'is_active',)
    fieldsets = (
        (None, {'fields': ('email', 'password')}),
        ('Permissions', {'fields': ('is_staff', 'is_active')}),
    )
    add_fieldsets = (
        (None, {
            'classes': ('wide',),
            'fields': ('email', 'password1', 'password2', 'is_staff', 'is_active')}
        ),
    )
    search_fields = ('email',)
    ordering = ('email',)


class StudentProfileInline(admin.TabularInline):
    model = StudentProfile
    fk_name = 'user'
    can_delete = False
    max_num = 1 
    verbose_name_plural = _('student profile')


class StudentUserAdmin(CustomUserAdmin):
    add_form = StudentSignUpForm
    model = Student
    inlines = (StudentProfileInline, )

# ...
admin.site.register(Student, StudentUserAdmin)
# settings.py

AUTH_USER_MODEL = 'school.User'

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

AUTHENTICATION_BACKENDS = (
    "allauth.account.auth_backends.AuthenticationBackend",
)

SITE_ID = 1

ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = True
ACCOUNT_SESSION_REMEMBER = True

php – Adding variable in WordPress shortcode

I have this shortcode [post color="XYZ" width="980" height="610]

I wish to pass $color in color=””. Here, $color is fetched from dynamic URL: www.mydomain.com/check/?color=BLUE $color is working fine otherwise, but I wish to pass it in the shortcode so that color is dynamically loaded on the page based on $color

How could this be achieved?

What are the pros and cons of adding SQL columns in run time, vs through a different design time architecture?

The company I’m currently working for has a feature in an enterprise app where a user can add columns to a table configuration on a web GUI through fields and a button, and a corresponding SQL table has columns added (or altered or removed). That is, the table is shaped in run time by the user’s preferences.

This feels wrong to me, but I’m struggling to clarify to myself and to others what the limitations are of this architecture vs one that uses a ‘design time’ style – for example, having the user’s input added as a row to a ‘Columns’ table, which includes a foreign key to the ‘Tables’ table.

This ‘run time’ approach doesn’t appear to violate the forms of normalization as far as I understand them. There’ll be a performance hit each time a table needs to be updated, but this is a niche business app with maybe a few dozen active users at a time in an organisation, so it doesn’t need to scale.

There are development/testing issues with this because adding test data means making corresponding database changes. But since testing is all manual at this company, and test databases are just copied wholesale between versions, it doesn’t seem to have as big an impact as one might think.

The GUI has a number of validation checks to ensure columns are added safely. I also feel uncomfortable that the front end (AngularJS) writes directly to the database, instead of going through a back end API, but again the application is niche enough that the company can ensure users always go through the GUI. And it’s installed on private corporate networks, so in theory it’s not exposed to public attacks on the database directly.

The company is very invested in the current architecture so is unlikely to change this app, but I’d like to at least build awareness about the consequences of this approach so future apps can be designed in a better way.

I’d like to understand the following:

  1. What are the performance differences between a user adding a column dynamically, vs adding a row in an existing table?
  2. What are the security vulnerabilities that this approach creates, if any?
  3. Are there any industry standards, guidelines or best practices I can reference as supporting one or other database design?

plugins – Adding Dynamic Attributes in Script Tag for 3rd party JS

I saw that someone had asked how to add attributes in script tag for 3rd party JS here: Adding Additional Attributes in Script Tag for 3rd party JS

My question is how to also make those attributes dynamic if I were to write a WordPress plugin that would take in a value that the user inputs via a widget.

The script_loader_tag filter only takes in 3 preset parameters ($handle, $tag, $src) so I can’t figure out how to add in custom params to the $tag = str_replace( 'src="https://wordpress.stackexchange.com/,"data-attribute="'.$dynamicvar.'" src=', $tag ); from the parent function it’s contained in.

Any help would be appreciated

magento2 – Adding label to text field

How can I add a label to the custom field in the checkout page? I can’t seem to find a source for that. Assuming code is like what is in the Mageplaza sample

<?php
$customAttributeCode = 'custom_field';
$customField = (
    'component' => 'Magento_Ui/js/form/element/abstract',
    'config' => (
        // customScope is used to group elements within a single form (e.g. they can be validated separately)
        'customScope' => 'shippingAddress.custom_attributes',
        'customEntry' => null,
        'template' => 'ui/form/field',
        'elementTmpl' => 'ui/form/element/input',
        'tooltip' => (
            'description' => 'this is what the field is for',
        ),
    ),
    'dataScope' => 'shippingAddress.custom_attributes' . '.' . $customAttributeCode,
    'label' => 'Custom Attribute',
    'provider' => 'checkoutProvider',
    'sortOrder' => 0,
    'validation' => (
       'required-entry' => true
    ),
    'options' => (),
    'filterBy' => null,
    'customEntry' => null,
    'visible' => true,
);

$jsLayout('components')('checkout')('children')('steps')('children')('shipping-step')('children')('shippingAddress')('children')('shipping-address-fieldset')('children')($customAttributeCode) = $customField;

How can I add a label here? I’m not talking about the placeholder what I’m looking for is an actual label

Does adding the Niche or keyword in the URL help with SEO?

Does adding the Niche or keyword in the URL help with SEO?

Adding WordPress Tags to the searched fields in customized search query

I have a website where I need to be able to search for Posts based on title, tags, and content of custom fields. I’ve made the modifications below to my functions.php file. (Code for including the custom fields was borrowed from here: https://adambalee.com/search-wordpress-by-custom-fields-without-a-plugin/)

This successfully searches by post title and my custom fields, but I need help with how to make further modifications to also search the TAGS on the post. I tried a few things but couldn’t get the results I was looking for.

// Hide PAGES from search results
function remove_pages_from_search($query) {
if ($query->is_search) {
    $query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','remove_pages_from_search');



// Make the search to index custom
/**
 * Extend WordPress search to include custom fields
 * http://adambalee.com
 *
 * Join posts and postmeta tables
 * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
 */
function cf_search_join( $join ) {
    global $wpdb;
    if ( is_search() ) {    
        $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
    }
    return $join;
}
add_filter('posts_join', 'cf_search_join' );

/**
 * Modify the search query with posts_where
 * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
 */
function cf_search_where( $where ) {
    global $pagenow, $wpdb;
    if ( is_search() ) {
        $where = preg_replace(
            "/(s*".$wpdb->posts.".post_titles+LIKEs*('(^')+')s*)/",
            "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1) ", $where );
    }
    return $where;
}
add_filter( 'posts_where', 'cf_search_where' );

/**
 * Prevent duplicates
 * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct
 */
function cf_search_distinct( $where ) {
    global $wpdb;
    if ( is_search() ) {
        return "DISTINCT";
    }
    return $where;
}
add_filter( 'posts_distinct', 'cf_search_distinct' );